<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>活动</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    html,body{
        width: 100%;
        height: 100%;
    }
 body{
     display: flex;
     justify-content: center;
     justify-items: center;
     align-items: center;
     background:no-repeat center center;
      background-image:url('./img/bg1.jpeg');
      background-size:cover;
  }
  .box{
      height: 600px;
      width: 600px;
      border:5px solid #ccc;
      border-radius: 50%;
      overflow: hidden;
      background:no-repeat center center;
      background-image:url('./img/2.jpeg');
      background-size:cover;
  }
</style>
<body>

    <div class="box" > 
        <!-- <img src="./img/2.jpeg" alt=""> -->
    </div>
    <audio loop  id="mp3" src="./lib/mp3/a1.mp3"></audio>
<script src="./lib/jquery.js"></script>
<script src="./img/data.js" ></script>
<script>
// 随机数
function GetRandomNum(Min,Max)
{
var Range = Max - Min;
var Rand = Math.random();
return(Min + Math.round(Rand * Range));
}
// 图片数据
var Data = ImagData;

$(function (){
    var status = false //
    var Tiem = null;
    $('body').on('click',function (){
        if (status ===false){
            Tiem=  Start();
            status =true;
        }else{
            stop();
            status =false;

        }
    })
   function Start() {
       $('#mp3')[0].play();
       return setInterval(function (){
        var  num =   GetRandomNum(1,Data.length)
        var Url = " url(./img/"+Data[num]+")"
        $('.box').css('background-image',Url)
       },100)
   } 
   function stop (){
    Tiem &&   clearInterval(Tiem);
    $('#mp3')[0].pause();
   }
})
</script>
</body>
</html>